package edu.kit.aifb.lidasora.ppmModel.transitionCount;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * Provides a function for different ways of counting the transitions
 * 
 * Provides a function for different ways of counting the transitions.
 * Especially with regard to false predictions and their weightings, this will
 * be important
 * 
 * @author Daniel
 * 
 */

public abstract class TransitionCount implements Cloneable{

	// save the number of overall transitions
	protected AtomicInteger count = new AtomicInteger(1);

	/**
	 * Call this method on successful prediction
	 * 
	 * Call this method on successful prediction, i.e. the transition count has
	 * to be incremented
	 */
	public abstract void truePrediction();

	/**
	 * call this method on false predictions
	 * 
	 * Call this method on false predictions
	 */
	public abstract void falsePrediction();

	/**
	 * Returns the transition value for this node
	 * 
	 * @return the transition value for this node
	 */
	public abstract double getTransitionValue();

	/**
	 * increments the count
	 * 
	 * increments the count. Call after each transition during learning or
	 * querying in tree, i.e. when there exist a sequence with this transition
	 * but no kind of prediction
	 */
	public void increment() {
		count.incrementAndGet();
	}

	/**
	 * Returns the count
	 * 
	 * returns the count
	 * 
	 * @return the count
	 */
	public int getCount() {
		return count.get();
	}
	
	/**
	 * resets this counter
	 */
	public void reset(){
		count = new AtomicInteger(1);
	}
	
	@Override 
	  public TransitionCount clone() 
	  { 
	    try 
	    { 
	 
	      return (TransitionCount) super.clone(); 
	    } 
	    catch ( CloneNotSupportedException e ) { 
	      // this shouldn't happen, since we are Cloneable 
	      throw new InternalError(); 
	    } 
	  } 
}
